package com.haiyuancloud.create.properties.abs;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.haiyuancloud.base.deal.core.chain.compile.model.HyDealDBModel;
import com.haiyuancloud.create.properties.HyDataSourceProperties;

public abstract class AbsHyDataSourceProperties implements HyDataSourceProperties {


    @NacosValue(value = "${spring.datasource.dynamic.hikari.connection-timeout}", autoRefreshed = true)
    private Long connectionTimeout;

    @NacosValue(value = "${spring.datasource.dynamic.hikari.max-lifetime}", autoRefreshed = true)
    private Long maxLifetime;

    @NacosValue(value = "${spring.datasource.dynamic.hikari.max-pool-size}", autoRefreshed = true)
    private Integer maxPoolSize;

    @NacosValue(value = "${spring.datasource.dynamic.hikari.min-idle}", autoRefreshed = true)
    private Integer minIdle;

    @NacosValue(value = "${spring.datasource.dynamic.hikari.connection-test-query}", autoRefreshed = true)
    private String connectionTestQuery;


    public abstract String getUrl() ;
    public abstract String getUsername();

    public abstract String getPassword();

    public abstract String getDataSource();

    @Override
    public HyDealDBModel getHyDealDBModel(){
        HyDealDBModel hyDealDBModel = new HyDealDBModel();
        hyDealDBModel.setDataSource(getDataSource());
        hyDealDBModel.setUrl(getUrl());
        hyDealDBModel.setUsername(getUsername());
        hyDealDBModel.setPassword(getPassword());
        hyDealDBModel.setMinIdle(minIdle);
        hyDealDBModel.setConnectionTestQuery(connectionTestQuery);
        hyDealDBModel.setMaxLifetime(maxLifetime);
        hyDealDBModel.setMaxPoolSize(maxPoolSize);
        hyDealDBModel.setConnectionTimeout(connectionTimeout);
        return hyDealDBModel;
    }
}
